﻿using System;
using BotDetector.Core.Detector;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BotDetector.Core.Model;

namespace BotDetector.Tests.DetectorTests
{
    [TestClass]
    public class ExactPhraseAnalyzorTests
    {
        BotDetector.Core.Detector.ExactPhraseAnalyzor detector;
        ResultItemList resultItemList;

        private void Initialize()
        {
            resultItemList = new ResultItemList();
            resultItemList.Add(new ResultItem
            {
                Title = "title",
                Description = "50 dolari reali gratuiti la Pokerstars pe acest link si mai uita-te aici",
                Url = "url"
            });

            resultItemList.Add(new ResultItem
            {
                Title = "title",
                Description = "numai aici ai parte de 50 dolari reali gratuiti la Pokerstars pe acest link",
                Url = "url"
            });
            resultItemList.Add(new ResultItem
            {
                Title = "title",
                Description = "la la la la 50 dolari reali gratuiti la Pokerstars pe acest link bla bla",
                Url = "url"
            });
            resultItemList.Add(new ResultItem
            {
                Title = "50 dolari reali gratuiti la Pokerstars pe acest link",
                Description = "la la",
                Url = "url"
            });
            resultItemList.Phrase = "50 dolari reali gratuiti la Pokerstars pe acest link";

        }
        private void InitializeShortBot()
        {
            detector = new BotDetector.Core.Detector.ExactPhraseAnalyzor(BotLength.Short);
        }
        private void InitializeMediumBot()
        {
            detector = new BotDetector.Core.Detector.ExactPhraseAnalyzor(BotLength.Medium);
        }
        private void InitializeLongBot()
        {
            detector = new BotDetector.Core.Detector.ExactPhraseAnalyzor(BotLength.Long);
        }
        [TestMethod]
        public void DetectValueForEachTypeOfBot_CorrectDataShortBot_True()
        {
            InitializeShortBot();
            Assert.IsTrue(detector.DetectValueForEachTypeOfBot(1, 1, 4, 6));
        }
        [TestMethod]
        public void DetectValueForEachTypeOfBot_IncorrectDataMediumBot_False()
        {
            InitializeMediumBot();
            Assert.IsFalse(detector.DetectValueForEachTypeOfBot(2, 1, 4, 6));
        }
        [TestMethod]
        public void DetectValueForEachTypeOfBot_CorrectDataLongBot_True()
        {
            InitializeLongBot();
            Assert.IsTrue(detector.DetectValueForEachTypeOfBot(8, 1, 4, 6));
        }
        public void CountResultsFoundWithExactPhrase_3Phrases_True()
        {
            Initialize();
            Assert.IsTrue(detector.CountResultsFoundWithExactPhrase(resultItemList) == 4);
        }
        public void AnalyzeAfterExactPhrase_Bot_True()
        {
            Initialize();
            Assert.IsTrue(detector.AnalyzeAfterExactPhrase(resultItemList));
        }
    }
}

